package com.deke.order.service.Impl;

import com.deke.entity.Chapter;
import com.deke.entity.Video;
import com.deke.order.dao.ChapterDao;
import com.deke.order.dao.VideoDao;
import com.deke.order.service.ChapterService;
import com.deke.vo.Result;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @version 1.0
 * @Author :LiM
 * @Date :2022/12/26 12:23
 */
@Service
public class ChapterServiceImpl implements ChapterService {
    @Resource
    private ChapterDao chapterDao;
    @Resource
    private VideoDao videoDao;
    /**
     * 通过课程id查询对应章节
     * @param courseId
     * @return
     */
    @Override
    public Result queryChapterByCourseId(String courseId) {
        List<Chapter> chapters = this.chapterDao.queryChapterByCourseId(courseId);
        for (Chapter chapter : chapters) {
            List<Video> videos = this.videoDao.queryByChapterId(chapter.getId());
            chapter.setVideo(videos);
        }
        return new Result(2000,"查询成功",chapters);
    }
}
